import { AlbumInfo, AlbumModel } from "./album";
import { AudioFrequencyInfo, AudioFrequencyModel } from "./audioFrequency";

/** 资源 模型 */
export class ResourcesModel {
  private _audioFrequency: AudioFrequencyModel[] = [];
  private _album: AlbumModel[] = [];

  /** 音频 */
  public get audioFrequency(): AudioFrequencyInfo[] {
    return this._audioFrequency.map(val => val.data);
  }
  public setAudioFrequency(list: AudioFrequencyInfo[]): void {
    list.map(val => {
      this.addAudioFrequency(val);
    })
  }
  public addAudioFrequency(data: AudioFrequencyInfo): void {
    const audioFrequency = new AudioFrequencyModel;
    audioFrequency.setData(data);
    this._audioFrequency.push(audioFrequency);
  }





  /** 相册 */
  public get album(): AlbumInfo[] {
    return this._album.map(val => val.data);
  }
  public setAlbum(list: AlbumInfo[]): void {
    list.map(val => {
      this.addAlbum(val);
    })
  }
  /**新建一个相册 */
  public addAlbum(data: AlbumInfo): void {
    const album = new AlbumModel;
    album.setData(data);
    this._album.push(album);
  }
  /** 获取某个相册 */
  public getAlbumOne(uid: string): AlbumModel {
    return this._album.filter(val => val.data.uid === uid)[0];
  }

}